#!/bin/bash
FETION_PATH=/opt/omreportsh
if [ ! -d "/opt/omreportsh" ];then
        mkdir -p $FETION_PATH
fi
wget http://rayangscripts.googlecode.com/svn/trunk/omreportmon.sh -O $FETION_PATH/omreportmon.sh
wget http://rayangscripts.googlecode.com/svn/trunk/tosendlist.txt -O $FETION_PATH/tosendlist.txt
wget http://rayangscripts.googlecode.com/svn/trunk/sendmail.jar -O $FETION_PATH/mail.jar
if [  -f "$FETION_PATH/omreportmon.sh" ] && [ -f "$FETION_PATH/tosendlist.txt" ] && [ -f "$FETION_PATH/mail.jar" ];then
        chmod +x $FETION_PATH/omreportmon.sh
	$FETION_PATH/omreportmon.sh
        if [ `cat /etc/crontab|grep "$FETION_PATH/omreportmon.sh"|wc -l` -eq 0 ];then
                echo "0 9 * * 1 root $FETION_PATH/omreportmon.sh" >> /etc/crontab
        fi
else
        echo "Download files failed" && exit 1
fi
